package com.updesignsz.admin.vo.form;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

/**
 * @author Lei
 * @since 1.0
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class UserForm implements Serializable {
    private static final long serialVersionUID = 7954211986565206161L;

    @NotNull(message = "用户ID不能为空", groups = PutMapping.class)
    private Integer id;

    @NotBlank(message = "用户名不能为空", groups = {PutMapping.class, PostMapping.class})
    @Length(min = 5, max = 15, message = "用户名长度应为{min}-{max}位", groups = {PutMapping.class, PostMapping.class})
    private String username;

    @NotEmpty(message = "密码不能为空", groups = {PostMapping.class})
    @Length(min = 8, max = 16, message = "密码长度应为{min}-{max}位", groups = {PostMapping.class})
    private String password;

    private String phomeNumber;

    private String remark;

    private List<Integer> roles;
}
